package mms

class MedicineRetail {
    
    static transients = ['SELL','BUY','RETURNED_SELL','RETURNED_BUY']
    static final SELL = 1
    static final BUY = 2
    static final RETURNED_SELL = 3
    static final RETURNED_BUY = 4

    Medicine medicine
    Integer retail = 1 // 零售类型，1销售，2入库，3，销售退货 4，
    Float amount = 0 //数量 ，正数是入库，，负数是出库 
    String validity = ""// 失效日期
    String department = ""// 门店
    String purchase = ""// 购货单位
    String batchNumber= "" //产品批号
    MedicineCompany company //
    Date dateCreated //日期
    String publish = ""
//    static hasMany = []
//    static belongsTo = []
//    static transients = []


//    table 'xedu_article'
//    sort  lastTime
    static mapping = {
        batchSize 50
        //dateCreated index:true
    }
    //blank 
    //email
    //inList
    //matches 
    //nullable 
    //size
    //unique
    //url 
    static constraints = {
        medicine(nullable:true)
        retail(inList:0..4)
        amount(blank:false)  
        validity(blank:true)  
        department(blank:true)  
        purchase(blank:true) // 购货单位
        batchNumber(blank:true)  //产品批号
        publish(blank:true)
        company(nullable:true)
        dateCreated()
    }

    String toString() { 
        "${medicine?.production} ${amount}"
    } 
}
